package com.zheng.study.company.service.impl;

import com.zheng.study.base.bean.BaseEnumManager;
import com.zheng.study.base.bean.search.SearchEnum;
import com.zheng.study.base.bean.search.order.Order;
import com.zheng.study.base.bean.search.result.SearchResultList;
import com.zheng.study.base.bean.search.rule.Rule;
import com.zheng.study.base.bean.search.rule.RuleHelper;
import com.zheng.study.base.dao.BaseDao;
import com.zheng.study.base.service.impl.BaseServiceImpl;
import com.zheng.study.company.dao.PostDao;
import com.zheng.study.company.entity.Company;
import com.zheng.study.company.entity.Post;
import com.zheng.study.company.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * newFile
 * ============================================================================
 * author : dzw
 * createDate:  2018/8/24 。
 * ============================================================================
 */
@Service
public class PostServiceImpl extends BaseServiceImpl<Post, String> implements PostService {

	@Autowired
	private PostDao postDao;

	@Override
	public BaseDao<Post, String> getBaseDao() {
		return postDao;
	}

	@Override
	public List<Post> getPostList(Company company) {
		Order order = Order.order("pinYinHead", SearchEnum.OrderType.asc);
		List<Rule> rules = new ArrayList<Rule>();
		rules.add(RuleHelper.eq("state", BaseEnumManager.StateEnum.Enable));
		rules.add(RuleHelper.eq("company", company));
		SearchResultList searchResult = findListBySearch(rules, order);
		return (List<Post>)searchResult.getList();
	}
}
